home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
byt85may.lbr
/
PI2.ASC
< prev
next >
Wrap
Text File
|
1985-09-15
|
1KB
|
40 lines
100 REM pi2.bas
105 REM
110 REM copyrighted 1984
115 REM by
120 REM David J. Crawford
125 REM
130 REM For private, non-commercial
135 REM use only
140 REM
150 REM
160 REM This program computes PI using the Taylor's Series Expansion
170 REM of "16 ARCTAN 1/5 - 4 ARCTAN 1/239."
180 REM
190 DEFDBL B-G,P
200 A=12 : B=16 : C=5
210 GOSUB 280
220 P1=P
230 A=4 : B=4 : C=239
240 GOSUB 280
250 PRINT "16 ARCTAN 1/5 - 4 ARCTAN 1/239 = PI"
260 PRINT P1,P,P1-P
270 STOP
280 REM *** This subroutine sums "A" terms of the Taylor's Series
290 REM for "B" times the angle whose tangent is (1/"C")
300 REM and returns the sum as "P."
310 PRINT "TAYLOR'S SERIES FOR";B;"ARCTAN( 1 /";C;")"
320 PRINT "TERM #";TAB(10);"RATIO";TAB(38);"DECIMAL";TAB(61);"SUBTOTAL"
330 D=1 : E=1 : F=C : P=0
340 FOR X=1 TO A
350 G=E*F
360 P=P+D*B/G
370 PRINT X;TAB(8)
380 IF SGN(D)=1 THEN PRINT "+"; ELSE PRINT "-";
390 PRINT STR$(B);" /";STR$(G);TAB(37);D*B/G;TAB(60);P
400 F=F*C*C
410 E=E+2
420 D=-D
430 NEXT X
440 PRINT : RETURN